package com.gz.service.impl;

import com.gz.entity.StudentQuestionTagWeights;
import com.gz.dao.StudentQuestionTagWeightsMapper;
import com.gz.service.StudentQuestionTagWeightsService;
import com.gz.vo.StudentQuestionTagWeightsVO;
import org.springframework.stereotype.Service;
import com.gz.dto.StudentQuestionTagWeightsDto;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gz.dto.PageData;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * (StudentQuestionTagWeights)表服务实现类
 *
 * @author jhk
 * @since 2024-07-18 20:41:13
 */
@Service
public class StudentQuestionTagWeightsServiceImpl implements StudentQuestionTagWeightsService {
    @Autowired
    private StudentQuestionTagWeightsMapper studentQuestionTagWeightsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param studentId 主键
     * @return 实例对象
     */
    @Override
    public List<StudentQuestionTagWeights> queryByStuId(Integer studentId) {
        return studentQuestionTagWeightsDao.queryByStId(studentId);
    }

    /**
     * 分页查询
     *
     * @param dto 筛选条件
     * @return 查询结果
     */
    @Override
    public PageData queryByPage(StudentQuestionTagWeightsDto dto) {
        PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
        List<StudentQuestionTagWeights> list = studentQuestionTagWeightsDao.queryAllByLimit(dto);
        PageInfo<StudentQuestionTagWeights> pageInfo = new PageInfo<>(list);
        return new PageData<>(pageInfo.getTotal(), list);
    }
    @Override
    public PageData queryStuWeitsByPage(StudentQuestionTagWeightsDto dto) {
        PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
        List<StudentQuestionTagWeightsVO> list = studentQuestionTagWeightsDao.queryStuWeitsByPage(dto);
        PageInfo<StudentQuestionTagWeightsVO> pageInfo = new PageInfo<>(list);
        return new PageData<>(pageInfo.getTotal(), list);
    }
    @Override
    public List<StudentQuestionTagWeights> queryAll(StudentQuestionTagWeightsDto dto){
        return studentQuestionTagWeightsDao.queryAll(dto);
    }

    /**
     * 新增数据
     *
     * @param studentQuestionTagWeights 实例对象
     * @return 实例对象
     */
    @Override
    public StudentQuestionTagWeights insert(StudentQuestionTagWeights studentQuestionTagWeights) {
        studentQuestionTagWeightsDao.insert(studentQuestionTagWeights);
        return studentQuestionTagWeights;
    }

    /**
     * 修改数据
     *
     * @param studentQuestionTagWeights 实例对象
     * @return 实例对象
     */
    @Override
    public StudentQuestionTagWeights update(StudentQuestionTagWeights studentQuestionTagWeights) {
        studentQuestionTagWeightsDao.update(studentQuestionTagWeights);
        return studentQuestionTagWeights;
    }

    /**
     * 通过主键删除数据
     *
     * @param studentId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer studentId) {
        return studentQuestionTagWeightsDao.deleteById(studentId) > 0;
    }
}
